/*
 * DeviceHttpHandler.cpp
 *
 *  Created on: 2017年7月24日
 *      Author: terry
 */

#include "DeviceHttpHandler.h"
#include "HttpUtil.h"
#include "TStringUtil.h"
#include "Socket.h"


DeviceHttpHandler::DeviceHttpHandler()
{
}

DeviceHttpHandler::~DeviceHttpHandler()
{
}

int DeviceHttpHandler::handleJsonApi(const mg_str& method, const mg_str& uri,
	const mg_str& query, const mg_str& body,
	std::string& json)
{
	if (HttpUtil::isOption(method))
	{
		return 0;
	}

	int rc = 404;
	if (mg_vcmp(&uri, "/api/deviceLogin") == 0)
	{
		rc = handleDeviceLogin(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setVideoBitStream") == 0)
	{
		rc = handleSetVideoBitStream(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setHue") == 0)
	{
		rc = handleSetHue(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setSaturation") == 0)
	{
		rc = handleSetSaturation(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setContrast") == 0)
	{
		rc = handleSetContrast(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setBrightness") == 0)
	{
		rc = handleSetBrightness(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setOsdInfo") == 0)
	{
		rc = handleSetOsdInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/setWifiInfo") == 0)
	{
		rc = handleSetWifiInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/enableMute") == 0)
	{
		rc = handleEnableMute(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/updateDev") == 0)
	{
		rc = handleUpdateDev(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getBatteryInfo") == 0)
	{
		rc = handleGetBatteryInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getDevInfo") == 0)
	{
		rc = handleGetDevInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getVideoBitStream") == 0)
	{
		rc = handleGetVideoBitStream(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getCameraInfo") == 0)
	{
		rc = handleGetCameraInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getIsMute") == 0)
	{
		rc = handleGetIsMute(query, body, json);
	}	
	else if (mg_vcmp(&uri, "/api/getDevUpdateInfo") == 0)
	{
		rc = handleGetDevUpdateInfo(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/getFileList") == 0)
	{
		rc = handleGetFileList(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/uploadFile") == 0)
	{
		rc = handleUploadFile(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/cameraReview") == 0)
	{
		rc = handleCameraReview(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/startLive") == 0)
	{
		rc = handleStartLive(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/stopLive") == 0)
	{
		rc = handleStopLive(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/startRecord") == 0)
	{
		rc = handleStartRecord(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/stopRecord") == 0)
	{
		rc = handleStopRecord(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/startPhoto") == 0)
	{
		rc = handleStartPhoto(query, body, json);
	}
	else if (mg_vcmp(&uri, "/api/endPhoto") == 0)
	{
		rc = handleEndPhoto(query, body, json);
	}

	return rc;
}

void DeviceHttpHandler::handleUpload(const char* name, const std::string& filepath)
{

}

int DeviceHttpHandler::handleFileApi(const mg_str& method, const mg_str& uri,
	const mg_str& query, const mg_str& body,
	std::string& resp, std::string& mime)
{
	// pass
	return ENOENT;
}

void DeviceHttpHandler::handleWebSocketFrame(unsigned char *data, size_t size, unsigned char flags)
{
	// pass
}

std::string DeviceHttpHandler::getReportUrl()
{
	return m_reportUrl;
}

void DeviceHttpHandler::setRecordDir(const std::string& dir, const std::string& url)
{
	m_recordDir = dir;
	m_recordUrl = url;
}

void DeviceHttpHandler::setError(int code, const std::string& desc, std::string& jsonText)
{
	jsonText = comn::StringUtil::format("{\"result\":%d, \"desc\": \"%s\"}", code, desc.c_str());
}

void DeviceHttpHandler::setResult(const std::string& result, const std::string& desc, std::string& jsonText)
{
	jsonText = comn::StringUtil::format("{\"result\":\"%s\", \"desc\": \"%s\"}", result.c_str(), desc.c_str());
}

void DeviceHttpHandler::setResult(int result, const std::string& desc, std::string& jsonText)
{
	jsonText = comn::StringUtil::format("{\"result\":%d, \"desc\": \"%s\"}", result, desc.c_str());
}

void DeviceHttpHandler::setResult(int result, std::string& jsonText)
{
	jsonText = comn::StringUtil::format("{\"result\":%d}", result);
}

void DeviceHttpHandler::setResult(const std::string& result, std::string& jsonText)
{
	jsonText = comn::StringUtil::format("{\"result\":\"%s\"}", result.c_str());
}

const char* DeviceHttpHandler::getErrorDesc(int err)
{
	if (err == 0)
	{
		return "成功";
	}
	return "失败";
}

int DeviceHttpHandler::handleSetVideoBitStream(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int stream = 0;
	int resolution = 0;
	int framerate = 0;
	int bitrate = 0;

	if (!HttpUtil::getVar(&query, "stream", stream))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "resolution", resolution))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "framerate", framerate))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "bitrate", bitrate))
	{
		return EINVAL;
	}

	int rc = setVideoBitStream(cameraNo, stream, resolution, framerate, bitrate);

	setError(rc, "", jsonText);

	return 0;
}

int DeviceHttpHandler::handleDeviceLogin(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string report;
	HttpUtil::getVar(&query, "report", report);

	int rc = deviceLogin(cameraNo, report);
	
	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetHue(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int hue = 0;
	if (!HttpUtil::getVar(&query, "hue", hue))
	{
		return EINVAL;
	}

	int rc = setHue(cameraNo, hue);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetSaturation(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int saturation = 0;
	if (!HttpUtil::getVar(&query, "saturation", saturation))
	{
		return EINVAL;
	}

	int rc = setSaturation(cameraNo, saturation);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetContrast(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int contrast = 0;
	if (!HttpUtil::getVar(&query, "contrast", contrast))
	{
		return EINVAL;
	}

	int rc = setContrast(cameraNo, contrast);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetBrightness(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int brightness = 0;
	if (!HttpUtil::getVar(&query, "brightness", brightness))
	{
		return EINVAL;
	}

	int rc = setBrightness(cameraNo, brightness);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetOsdInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string osdStr;
	if (!HttpUtil::getVar(&query, "osdStr", osdStr))
	{
		return EINVAL;
	}

	int displayLocation = 0;
	HttpUtil::getVar(&query, "displayLocation", displayLocation);

	int rc = setOsdInfo(cameraNo, osdStr, displayLocation);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleSetWifiInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string ssid;
	int type = 0;
	std::string password;

	if (!HttpUtil::getVar(&query, "ssid", ssid))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "type", type))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "password", password))
	{
		return EINVAL;
	}

	int rc = setWifiInfo(cameraNo, ssid, type, password);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleEnableMute(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int enable = 0;
	if (!HttpUtil::getVar(&query, "enable", enable))
	{
		return EINVAL;
	}

	int rc = enableMute(cameraNo, enable > 0);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleUpdateDev(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string updateUrl;
	std::string newVersion;
	HttpUtil::getVar(&query, "updateUrl", updateUrl);
	HttpUtil::getVar(&query, "newVersion", newVersion);

	int rc = updateDev(cameraNo, updateUrl, newVersion);

	setResult(rc, getErrorDesc(rc), jsonText);

	return 0;
}

int DeviceHttpHandler::handleGetBatteryInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int percent = 0;
	int rc = getBatteryInfo(cameraNo, percent);

	std::string result = comn::StringUtil::format("%d%%", percent);

	setResult(result, getErrorDesc(0), jsonText);

	return 0;
}

int DeviceHttpHandler::handleGetDevInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string version;
	float totalSpace = 0.0f;
	float freeSpace = 0.0f;
	int state = 0;

	int rc = getDevInfo(cameraNo, version, totalSpace, freeSpace, state);

	Json::Value value;
	value["version"] = version;
	value["total"] = totalSpace;
	value["free"] = freeSpace;
	value["state"] = state;

	jsonText = value.toStyledString();
	return rc;
}

int DeviceHttpHandler::handleGetVideoBitStream(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int stream = 0;
	int resolution = 0;
	int framerate = 0;
	int bitrate = 0;

	int rc = getVideoBitStream(cameraNo, stream, resolution, framerate, bitrate);

	Json::Value mainstream;
	mainstream["stream"] = stream;
	mainstream["resolution"] = resolution;
	mainstream["framerate"] = framerate;
	mainstream["bitrate"] = bitrate;

	stream = 1;
	getVideoBitStream(cameraNo, stream, resolution, framerate, bitrate);

	Json::Value subStream;
	subStream["stream"] = stream;
	subStream["resolution"] = resolution;
	subStream["framerate"] = framerate;
	subStream["bitrate"] = bitrate;

	Json::Value json;
	json["mainstream"] = mainstream;
	json["subStream"] = subStream;

	int livestream = 0;
	json["livestream"] = livestream;
	
	jsonText = json.toStyledString();
	return rc;
}

int DeviceHttpHandler::handleGetCameraInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int hue = 0;
	int saturation = 0;
	int contrast = 0;
	int brightness = 0;

	int rc = getCameraInfo(cameraNo, hue, saturation, contrast, brightness);

	Json::Value value;
	value["hue"] = hue;
	value["saturation"] = saturation;
	value["contrast"] = contrast;
	value["brightness"] = brightness;

	jsonText = value.toStyledString();
	return rc;
}

int DeviceHttpHandler::handleGetIsMute(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int result = getIsMute(cameraNo);

	setResult(result, jsonText);

	return 0;
}

int DeviceHttpHandler::handleGetDevUpdateInfo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string version;
	if (!HttpUtil::getVar(&query, "version", version))
	{
		return EINVAL;
	}

	int rc = getDevUpdateInfo(cameraNo, version);

	setResult(version, jsonText);

	return 0;
}

int DeviceHttpHandler::handleGetFileList(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string startTime;
	std::string endTime;
	if (!HttpUtil::getVar(&query, "startTime", startTime))
	{
		return EINVAL;
	}

	if (!HttpUtil::getVar(&query, "endTime", endTime))
	{
		return EINVAL;
	}

	RecordFileArray files;
	int rc = getFileList(cameraNo, startTime, endTime, files);

	Json::Value value;
	Json::Value objects(Json::arrayValue);

	for (size_t i = 0; i < files.size(); ++i)
	{
		Json::Value item;
		item["type"] = files[i].type;
		item["name"] = files[i].name;
		item["downLoadUrl"] = files[i].downLoadUrl;
		objects.append(item);
	}

	value["object"] = objects;


	jsonText = value.toStyledString();

	return 0;
}

int DeviceHttpHandler::handleUploadFile(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string caseNumber;
	HttpUtil::getVar(&query, "caseNumber", caseNumber);
	
	std::string uploadUrl;
	HttpUtil::getVar(&query, "caseNumber", caseNumber);

	int viaNetwork = 0;
	HttpUtil::getVar(&query, "viaNetwork", viaNetwork);

	std::string fileNames;
	HttpUtil::getVar(&query, "fileNames", fileNames);

	int rc = uploadFile(cameraNo, caseNumber, viaNetwork, uploadUrl,  fileNames);

	return 0;
}

int DeviceHttpHandler::handleCameraReview(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string url;
	int rc = cameraReview(cameraNo, url);

	setResult(url, jsonText);

	return 0;
}

int DeviceHttpHandler::handleStartLive(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string caseNumber;
	std::string recordId;
	std::string liveProtocol;
	std::string pushUrl;
	int stream = 0;
	std::string liveNoticeUrl;
	HttpUtil::getVar(&query, "caseNumber", caseNumber);
	HttpUtil::getVar(&query, "recordId", recordId);
	HttpUtil::getVar(&query, "liveProtocol", liveProtocol);
	HttpUtil::getVar(&query, "pushUrl", pushUrl);
	HttpUtil::getVar(&query, "stream", stream);
	HttpUtil::getVar(&query, "liveNoticeUrl", liveNoticeUrl);

	int rc = startLive(cameraNo, caseNumber, recordId, liveProtocol, pushUrl, stream, liveNoticeUrl);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleStopLive(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int rc = stopLive(cameraNo);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleStartRecord(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string caseNumber;
	std::string recordId;
	HttpUtil::getVar(&query, "caseNumber", caseNumber);
	HttpUtil::getVar(&query, "recordId", recordId);

	int rc = startRecord(cameraNo, caseNumber, recordId);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleStopRecord(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	int rc = stopRecord(cameraNo);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleStartPhoto(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string recordId;
	HttpUtil::getVar(&query, "recordId", recordId);

	int rc = startPhoto(cameraNo, recordId);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleEndPhoto(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string recordId;
	HttpUtil::getVar(&query, "recordId", recordId);

	int rc = endPhoto(cameraNo, recordId);

	setResult(rc, jsonText);

	return 0;
}

int DeviceHttpHandler::handleRecordReviewByVideo(const mg_str& query, const mg_str& body, std::string& jsonText)
{
	std::string cameraNo;
	HttpUtil::getVar(&query, "cameraNo", cameraNo);

	std::string videoName;
	HttpUtil::getVar(&query, "videoName", videoName);

	std::string rtspUrl;
	int rc = recordReviewByVideo(cameraNo, videoName, rtspUrl);

	Json::Value json;
	json["rtspUrl"] = rtspUrl;

	jsonText = json.toStyledString();

	return rc;
}



int DeviceHttpHandler::deviceLogin(const std::string& cameraNo, const std::string& report)
{
	m_reportUrl = report;

	printf("%s\n", report.c_str());

	return 0;
}

int DeviceHttpHandler::setVideoBitStream(const std::string& cameraNo, int stream, int resolution, int framerate, int bitrate)
{
	return 0;
}

int DeviceHttpHandler::setHue(const std::string& cameraNo, int hue)
{
	return 0;
}

int DeviceHttpHandler::setSaturation(const std::string& cameraNo, int saturation)
{
	return 0;
}

int DeviceHttpHandler::setContrast(const std::string& cameraNo, int contrast)
{
	return 0;
}

int DeviceHttpHandler::setBrightness(const std::string& cameraNo, int brightness)
{
	return 0;
}

int DeviceHttpHandler::setOsdInfo(const std::string& cameraNo, const std::string& osdstr, int displayLocation)
{
	return 0;
}

int DeviceHttpHandler::setWifiInfo(const std::string& cameraNo, const std::string& ssid, int type, const std::string& password)
{
	return 0;
}

int DeviceHttpHandler::enableMute(const std::string& cameraNo, bool muted)
{
	return 0;
}

int DeviceHttpHandler::updateDev(const std::string& cameraNo, const std::string& updateUrl, const std::string& newVersion)
{
	return 0;
}

int DeviceHttpHandler::getBatteryInfo(const std::string& cameraNo, int& percent)
{
	//
	percent = 50;

	return 0;
}

int DeviceHttpHandler::getDevInfo(const std::string& cameraNo, std::string& version, float& totalSpace, float& freeSpace, int& state)
{
	version = "1.0.1";
	totalSpace = 100;
	freeSpace = 80;
	state = 0;

	return 0;
}

int DeviceHttpHandler::getVideoBitStream(const std::string& cameraNo, int& stream, int& resolution, int& framerate, int& bitrate)
{
	resolution = 0;
	framerate = FPS_25;
	bitrate = 128;

	return 0;
}

int DeviceHttpHandler::getCameraInfo(const std::string& cameraNo, int& hue, int& saturation, int& contrast, int& brightness)
{
	hue = 1;
	saturation = 2;
	contrast = 3;
	brightness = 4;

	return 0;
}

int DeviceHttpHandler::getIsMute(const std::string& cameraNo)
{
	return 0;
}

int DeviceHttpHandler::getDevUpdateInfo(const std::string& cameraNo, std::string& version)
{
	version = "1.0.1";

	return 0;
}

int DeviceHttpHandler::getFileList(const std::string& cameraNo, const std::string& startTime, const std::string& endTime, RecordFileArray& files)
{
	{
		RecordFile file;
		file.type = RECORD_TYPE_MEDIA;
		file.name = "demo.mp4";
		file.downLoadUrl = m_recordUrl + "/demo.mp4";
		files.push_back(file); 
	}
	{
		RecordFile file;
		file.type = RECORD_TYPE_MEDIA;
		file.name = "480.ts";
		file.downLoadUrl = m_recordUrl + "/480.ts";
		files.push_back(file);
	}

	{
		RecordFile file;
		file.type = RECORD_TYPE_IMAGE;
		file.name = "snap.jpeg";
		file.downLoadUrl = m_recordUrl + "/snap.jpeg";
		files.push_back(file);
	}

	return 0;
}

int DeviceHttpHandler::uploadFile(const std::string& cameraNo, const std::string& caseNumber,
	int viaNetwork, const std::string& uploadUrl, const std::string& fileNames)
{
	return 0;
}

int DeviceHttpHandler::cameraReview(const std::string& cameraNo, std::string& url)
{
	std::string ip = comn::SockAddr::getLocalIP();
	int port = 554;
	url = comn::StringUtil::format("rtsp://%s:%d/live", ip.c_str(), port);

	return 0;
}

int DeviceHttpHandler::startLive(const std::string& cameraNo, const std::string& caseNumber, const std::string& recordId, const std::string& liveProtocol,
	const std::string& pushUrl, int stream, const std::string& liveNoticeUrl)
{
	return 0;
}

int DeviceHttpHandler::stopLive(const std::string& cameraNo)
{
	return 0;
}

int DeviceHttpHandler::startRecord(const std::string& cameraNo, const std::string& caseNumber, const std::string& recordId)
{
	return 0;
}

int DeviceHttpHandler::stopRecord(const std::string& cameraNo)
{
	return 0;
}

int DeviceHttpHandler::startPhoto(const std::string& cameraNo, const std::string& recordId)
{
	return 0;
}

int DeviceHttpHandler::endPhoto(const std::string& cameraNo, const std::string& recordId)
{
	return 0;
}

int DeviceHttpHandler::recordReviewByVideo(const std::string& cameraNo, const std::string& videoName,  std::string& rtspUrl)
{
	std::string ip = comn::SockAddr::getLocalIP();
	int port = 554;
	rtspUrl = comn::StringUtil::format("rtsp://%s:%d/vod/%s", ip.c_str(), port, videoName.c_str());
	return 0;
}